import axios from 'axios';

import { Indicator } from 'mint-ui';
//新建一个 axios 实例
const axInstance = axios.create({
    baseURL: "https://www.fastmock.site/mock/18f6d9447d736821137122b262547233/api",
    timeout: 5000
});

//拦截器，请求拦截
axInstance.interceptors.request.use(config => {
    //加载动画
    Indicator.open();
    return config; //一定要返回一个值，否则下个res为未定义
}, err => {
    return Promise.reject(err)
});

//响应拦截
axInstance.interceptors.response.use(config => {
    Indicator.close();
    return config
}, err => {
    return Promise.reject(err)
})

export default axInstance;